package com.googlecode.maven.plugin.appassembler;

import java.io.File;
import java.io.FileFilter;
import java.util.HashSet;
import java.util.Set;

/**
 * The standard file exclusion filter (filtering out source control management
 * files).
 */
public class StandardExcludesFileFilter
        implements FileFilter
    {
    /**
     * Singleton instance of this file filter.
     */
    public static final StandardExcludesFileFilter INSTANCE = new StandardExcludesFileFilter();
    /**
     * Set of excluded file names.
     */
    private final Set<String> excludeNames = new HashSet<String>();

    /**
     * Constructs a new StandardExcludesFileFilter object.
     */
    public StandardExcludesFileFilter()
        {
        super();

        excludeNames.add("CVS");
        excludeNames.add(".cvsignore");
        excludeNames.add("SCCS");
        excludeNames.add("vssver.scc");
        excludeNames.add(".svn");
        excludeNames.add(".DS_Store");
        excludeNames.add(".git");
        excludeNames.add(".gitattributes");
        excludeNames.add(".gitignore");
        excludeNames.add(".gitmodules");
        excludeNames.add(".hg");
        excludeNames.add(".hgignore");
        excludeNames.add(".hgsub");
        excludeNames.add(".hgsubstate");
        excludeNames.add(".hgtags");
        excludeNames.add(".bzr");
        excludeNames.add(".bzrignore");
        }

    /**
     * {@inheritDoc}
     */
    public boolean accept(File file)
        {
        if (excludeNames.contains(file.getName()))
            {
            return false;
            }
        return true;
        }
    }
